import { types } from "mobx-state-tree"
import http from "../services/api/apiLibrary"
import { Alert } from "react-native"

export const EventStoreModel = types
  .model("EventStoreModel", {
    leagueData: types.frozen(),
    sportMap: types.frozen()
  })
  .actions(self => ({
    refreshData(leagueData) {
      self.leagueData = leagueData
    },

    loadData() {
      http
        .psotAtypia("/match/rec2", "")
        .then((data: any) => {
          this.refreshData(data.data)
        })
        .catch(error => {
          Alert.alert("请求失败", error.toString())
        })
    }
  }))
